package com.kfm.servlet;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "helloServlet", value = "/hello")
public class HelloServlet extends HttpServlet {



    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        request.setCharacterEncoding("utf-8");

        // xxx/hello?name=xxx
        String name = request.getParameter("name");

        System.out.println(name);


//        response.setHeader("content-type", "text/plain;charset=utf-8");
        response.setContentType("text/plain;charset=utf-8");
        PrintWriter writer = response.getWriter();

        writer.write("hello " + name);

    }
}
